using System;
using System.Collections.Generic;
using System.Text;

using Pampa.Grid.Core.Filters;

namespace Pampa.Grid.Core
{
    public class TypesHelper
    {
        /// <summary>
        /// Devuelve los operadores posibles para cada tipo de dato
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static IList<OperationType> GetAllowableOperations(Type type)
        {
            IList<OperationType> ops = new List<OperationType>();

            switch (type.Name)
            {
                case "String":
                    ops.Add(OperationType.Equal);
                    ops.Add(OperationType.NotEqual);
                    ops.Add(OperationType.Contains);
                    ops.Add(OperationType.EndsWith);
                    ops.Add(OperationType.StartsWith);
                    break;
                case "Int32":
                case "Single":
                case "Double":
                case "Decimal":
                case "DateTime":
                    ops.Add(OperationType.Equal);
                    ops.Add(OperationType.NotEqual);
                    ops.Add(OperationType.Grater);
                    ops.Add(OperationType.GraterEqual);
                    ops.Add(OperationType.Less);
                    ops.Add(OperationType.LessEqual);
                    break;
                default:
                    ops.Add(OperationType.Equal);
                    ops.Add(OperationType.NotEqual);
                    break;
            }

            return ops;
        }

        public static string GetOperationTypeDescription(OperationType type)
        {
            switch (type)
            {
                case OperationType.Grater:
                    return Resources.Operations.Grater;
                case OperationType.GraterEqual:
                    return Resources.Operations.GraterEqual;
                case OperationType.Less:
                    return Resources.Operations.Less;
                case OperationType.LessEqual:
                    return Resources.Operations.LessEqual;
                case OperationType.Equal:
                    return Resources.Operations.Equal;
                case OperationType.NotEqual:
                    return Resources.Operations.NotEqual;
                case OperationType.Contains:
                    return Resources.Operations.Contains;
                case OperationType.StartsWith:
                    return Resources.Operations.StarWidth;
                case OperationType.EndsWith:
                    return Resources.Operations.EndWidth;
                default:
                    return "Unknow Operation";
            }
        }
    }
}
